package com.lx.mobileplayer.mvp.persenter

import com.lx.mobileplayer.mvp.model.YueDanItemBean
import com.lx.mobileplayer.mvp.view.Iview.IYueDanView
import com.lx.mobileplayer.net.OkHttpUtil
import com.lx.mobileplayer.net.URLProvider


/**
 * 类说明：首页的presenter
 * Created by liuxiong on 2019/4/27.
 */
class YueDanPresenter(view:IYueDanView<YueDanItemBean.PlayListsBean>):BasePresenter<IYueDanView<YueDanItemBean.PlayListsBean>>(view) {

    fun requestData(offset:Int,pageSize:Int){

        var url= URLProvider.getYueDanUrl(offset,pageSize)

        OkHttpUtil.instance.request(url,object : OkHttpUtil.ResultCallBack<YueDanItemBean>() {
            override fun succecss(data: YueDanItemBean) {
                getView().loadSuccess(data.playLists as ArrayList<YueDanItemBean.PlayListsBean>)
            }

            override fun failed(code: Int, errorMessage: String) {
                getView().loadFailed(code,errorMessage)
            }
        })

    }

}